package cn.afactory.tygz.ui.activities;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.AttributeSet;
import android.view.View;

import com.lidroid.xutils.view.annotation.ContentView;
import com.tendcloud.tenddata.TCAgent;

import cn.afactory.tygz.R;
import cn.afactory.tygz.ui.base.BaseFragmentActivity;
import cn.afactory.tygz.ui.fragments.ApartmentListFragment;


/**
 * 人才公寓
 */
public class ApartmentListActivity extends BaseFragmentActivity {
    private ApartmentListFragment mFragment;

    private int mPageIndex = 0;
    public void setPageIndex(int index) {
        mPageIndex = index;
    }
    private void initTitleBar() {
        setTitleText(getString(R.string.title_apartment_list));
        showBackView();
    }

    /**
     * 跳转到人才公寓列表页面
     * @param context
     */
    public static void gotoApartmentListPage(Context context){
        Intent intent = new Intent(context,ApartmentListActivity.class);
        context.startActivity(intent);
    }

    @Override
    public View onCreateView(String name, Context context, AttributeSet attrs) {
        return super.onCreateView(name, context, attrs);
    }

    @Override
    public void onResume() {
        super.onResume();
        TCAgent.onResume(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_fragment);
        initview();
        initTitleBar();
    }

    private void initview() {
        mFragment = new ApartmentListFragment();
        if (mFragment != null) {
            addFragment(mFragment);
        } else {
            finish();
        }
    }

    private void addFragment(Fragment fragment) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.fl_layout, fragment, "" + fragment.getClass())
                .commit();
    }
}